package com.eascs.workflow.dictionary.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.workflow.common.entity.wf.DicData;
import com.eascs.workflow.common.vo.ModelResult;
import com.eascs.workflow.dictionary.dao.DicDataDao;
import com.eascs.workflow.dictionary.service.DicDataServiceInlet;

@Service
public class DicDataServiceInletImpl implements DicDataServiceInlet{
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    
	@Autowired
	private DicDataDao dicDataDao;
	
	@Override
	public ModelResult<List<DicData>> getDicDataByType(String dataType) {
		ModelResult<List<DicData>> modelResult = new ModelResult<>();
		try {
			modelResult.withModel(dicDataDao.getDicDataByType(dataType));
		} catch (Exception e) {
			modelResult.withError("DicDataServiceInletImpl.getDicDataByType", "查询数据字典失败");
			logger.error("查询数据字典失败,dataType：{},errMsg:{}", dataType, e.getMessage());
		}
		return modelResult;
	}
	
	@Override
	public ModelResult<List<DicData>> getDicDataByTypeAndKeys(String dataType, List<String> keys) {
		ModelResult<List<DicData>> modelResult = new ModelResult<>();
		try {
			modelResult.withModel(dicDataDao.getDicDataByTypeAndKeys(dataType, keys));
		} catch (Exception e) {
			modelResult.withError("DicDataServiceInletImpl.getDicDataByTypeAndKeys", "查询数据字典失败");
			logger.error("查询数据字典失败,dataType：{},errMsg:{}", dataType, e.getMessage());
		}
		return modelResult;
	}
}
